package org.reliablesource.jdt.model;

import org.eclipse.jdt.core.IJavaElement;
import org.reliablesource.model.core.ReliableNode;

/**
 * 
 * SourceElementInfo.java<br>
 * Copyright (c) 2007, Reliable Source, Inc. All Rights Reserved<br>
 * <br>
 * 
 * Created on: Apr 18, 2007 <br>
 * <br>
 * 
 * @author Dennis Park <a
 *         href="mailto:dennis.park@gmail.com">dennis.park@gmail.com</a>
 * 
 */
public class SourceElementInfo extends ReliableNode implements
		ISourceElementInfo {

	private static final long serialVersionUID = 3509054934028096773L;

	protected int numLines;
	protected String lastModified;
	protected String packageName;
	protected String projectName;
	protected IJavaElement javaElement;

	public SourceElementInfo() {
		super();
		numLines = 0;
	}

	public SourceElementInfo(String _fileName) {
		this();
		setName(_fileName);
	}

	public SourceElementInfo(String _fileName, int _lines) {
		this(_fileName);
		setNumLines(_lines);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.reliablesource.jdt.linecounter.IJavaElementInfo#getNumLines()
	 */
	public String getNumLines() {
		return Integer.toString(numLines).trim();
	}

	/**
	 * @param numLines
	 *            the numLines to set
	 */
	public void setNumLines(int _numLines) {
		if (_numLines < 1)
			_numLines = 0;
		numLines = _numLines;
		propertyMap.put(ISourceElementInfo.NUM_LINES, new Integer(numLines)
				.toString());
		setChanged();
	}

	/**
	 * @param numLines
	 *            the numLines to set
	 */
	public void setModified(String _modified) {
		if (null == _modified)
			return;
		lastModified = _modified;
		propertyMap.put(ISourceElementInfo.MODIFIED, lastModified);
		setChanged();
	}

	public String getModified() {
		return lastModified;
	}

	public IJavaElement getJavaElement() {
		return javaElement;
	}

	public void setJavaElement(IJavaElement _elt) {
		javaElement = _elt;
	}
}
